package com.mtk.launcher.util;


import com.mtk.launcher.bean.TimeCardEntity;

import java.util.Calendar;

public class TimeChangeUtil {


    public static TimeCardEntity getCurrentTime() {
        Calendar calendar = Calendar.getInstance();
        TimeCardEntity timeCardEntity = new TimeCardEntity("0", "0", "0", "0", "0", "0");
        try {
            int hour = calendar.get(Calendar.HOUR_OF_DAY);
            int minute = calendar.get(Calendar.MINUTE);
            int sec = calendar.get(Calendar.SECOND);
//            MyLog.playTask("timeCardEntity=0=" + hour + " / " + minute + " / " + sec);
            String formattedHour = String.format("%02d", hour);
            String formattedMinute = String.format("%02d", minute);
            String formattedSec = String.format("%02d", sec);
            char[] hourChars = formattedHour.toCharArray();
            char[] minuteChars = formattedMinute.toCharArray();
            char[] secChars = formattedSec.toCharArray();
            timeCardEntity = new TimeCardEntity(String.valueOf(hourChars[0]),
                String.valueOf(hourChars[1]),
                String.valueOf(minuteChars[0]),
                String.valueOf(minuteChars[1]),
                String.valueOf(secChars[0]),
                String.valueOf(secChars[1])
            );
        } catch (Exception e) {
            e.printStackTrace();
        }
        return timeCardEntity;
    }

}
